﻿using Bandit.Helpers;
using Bandit.UI.MVVM;
using ETC.DLEDLightingSystemPlus.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Input;

namespace ETC.DLEDLightingSystemPlus.ViewModels
{
    public class TestConfigViewModel : NotifyObject
    {
        #region 配置信息
        public ConfigInfo ConfigInfo { get; set; }
        #endregion

        

        #region NewLEDModel
        private int _NewDiyLEDRows;
        public int NewDiyLEDRows
        {
            get { return _NewDiyLEDRows; }
            set
            {
                _NewDiyLEDRows = value;
                OnPropertyChanged(nameof(NewDiyLEDRows));
            }
        }

        private int _NewDiyLEDCols;
        public int NewDiyLEDCols
        {
            get { return _NewDiyLEDCols; }
            set
            {
                _NewDiyLEDCols = value;
                OnPropertyChanged(nameof(NewDiyLEDCols));
            }
        }

        private ObservableCollection<DIYLedModel> _NewLedModelList = new ObservableCollection<DIYLedModel>();

        public ObservableCollection<DIYLedModel> NewLedModelList
        {
            get { return _NewLedModelList; }
            set
            {
                _NewLedModelList = value;
                OnPropertyChanged(nameof(NewLedModelList));
            }
        }

        private int _NewLightValue = 100;

        public int NewLightValue
        {
            get { return _NewLightValue; }
            set
            {
                _NewLightValue = value;
                OnPropertyChanged(nameof(NewLightValue));
            }
        }

        #endregion

        #region TempLEDModel
        private int _TempDiyLEDRows;
        public int TempDiyLEDRows
        {
            get { return _TempDiyLEDRows; }
            set
            {
                _TempDiyLEDRows = value;
                OnPropertyChanged(nameof(TempDiyLEDRows));
            }
        }

        private int _TempDiyLEDCols;
        public int TempDiyLEDCols
        {
            get { return _TempDiyLEDCols; }
            set
            {
                _TempDiyLEDCols = value;
                OnPropertyChanged(nameof(TempDiyLEDCols));
            }
        }

        private ObservableCollection<DIYLedModel> _TempLedModelList = new ObservableCollection<DIYLedModel>();

        public ObservableCollection<DIYLedModel> TempLedModelList
        {
            get { return _TempLedModelList; }
            set
            {
                _TempLedModelList = value;
                OnPropertyChanged(nameof(TempLedModelList));
            }
        }
        #endregion

        #region TempQiPanLEDModel
        private int _TempDiyQiPanLEDRows;
        public int TempDiyQiPanLEDRows
        {
            get { return _TempDiyQiPanLEDRows; }
            set
            {
                _TempDiyQiPanLEDRows = value;
                OnPropertyChanged(nameof(TempDiyQiPanLEDRows));
            }
        }

        private int _TempDiyQiPanLEDCols;
        public int TempDiyQiPanLEDCols
        {
            get { return _TempDiyQiPanLEDCols; }
            set
            {
                _TempDiyQiPanLEDCols = value;
                OnPropertyChanged(nameof(TempDiyQiPanLEDCols));
            }
        }

        private ObservableCollection<DIYLedModel> _TempQiPanLedModelList = new ObservableCollection<DIYLedModel>();

        public ObservableCollection<DIYLedModel> TempQiPanLedModelList
        {
            get { return _TempQiPanLedModelList; }
            set
            {
                _TempQiPanLedModelList = value;
                OnPropertyChanged(nameof(TempQiPanLedModelList));
            }
        }
        #endregion

        #region OnClick
        /// <summary>
        /// Click Event
        /// </summary>
        public ICommand OnClick { get; set; }
        #endregion

        #region LedInfoExcels

        private List<LogInfoExcelMode> _xlsNames;

        public List<LogInfoExcelMode> xlsNames
        {
            get { return _xlsNames; }
            set
            {
                _xlsNames = value;
                OnPropertyChanged("xlsNames");
            }
        }
        #endregion

        #region Constructors[构造函数]

        public TestConfigViewModel()
        {
            LoadxlsNames();

            this.ConfigInfo = new ConfigInfo();

        }

        #endregion

        public void LoadxlsNames()
        {
            this.xlsNames = new List<LogInfoExcelMode>();
            DirectoryInfo di = new DirectoryInfo("".GetBaseDirectory() + "LEDTemplateFiles\\");
            FileInfo[] files = di.GetFiles();
            foreach (FileInfo fi in files)
            {
                if (fi.Extension.Equals(".xlsx") && fi.Name.ToLower().Contains("ledinfo"))
                {
                    LogInfoExcelMode logInfoExcelMode = new LogInfoExcelMode();
                    logInfoExcelMode.Name = fi.Name;
                    logInfoExcelMode.ExcelPath = fi.Name;
                    this.xlsNames.Add(logInfoExcelMode);
                }
            }
        }

    }
}
